src: include cwd in chdir error message#21526
Conversation
Include the current working directory in the error message for a failing `process.chdir()` since that is usually information relevant for debugging. This is semver-major because it moves properties of the error message object. Inspired by nodejs/help#1355.
|
This needs another @nodejs/tsc review |
|
Resume Build for CI: https://ci.nodejs.org/job/node-test-pull-request/15697/ |
|
Resume Build did not work out. Let's try this instead for the only failed platform (Windows): https://ci.nodejs.org/job/node-test-commit-windows-fanned/19064/ EDIT: Green! All good on CI front. |
joyeecheung
left a comment
There was a problem hiding this comment.
LGTM with a question about a potential edge case
| // be helpful information when debugging a `chdir()` failure. | ||
| char buf[CHDIR_BUFSIZE]; | ||
| size_t cwd_len = sizeof(buf); | ||
| uv_cwd(buf, &cwd_len); |
There was a problem hiding this comment.
Is it possible that uv_cwd here returns something different from the original cwd? (I am thinking about Windows since libuv calls SetCurrentDirectoryW after SetCurrentDirectoryW and SetEnvironmentVariableW might fail even after SetCurrentDirectoryW succeeds)
There was a problem hiding this comment.
@joyeecheung I guess so? It’s not really clear to me how SetEnvironmentVariableW could fail with a runtime error…
I don’t think we really need to worry about it? It’s going to be pretty rare, I think
|
Landed in cf37945 |
Include the current working directory in the error message for a failing `process.chdir()` since that is usually information relevant for debugging. This is semver-major because it moves properties of the error message object. Inspired by nodejs/help#1355. PR-URL: #21526 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Include the current working directory in the error
message for a failing
process.chdir()since that isusually information relevant for debugging.
This is semver-major because it moves properties
of the error message object.
Inspired by nodejs/help#1355.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes